import { BasicColumn } from '@/components/Table';
import { h } from 'vue';
import { Divider, Tag, Tooltip } from 'ant-design-vue';
import { useI18n } from '@/hooks/web/useI18n';
import dayjs, { Dayjs } from 'dayjs';
import { currentyOptions } from '/@/settings/commonSetting';
import cdBlockCurrency from '/@/components-cd/block/cd-block-currency.vue';

const { t } = useI18n();

const setTooltip = (text) => {
  return h(
    Tooltip,
    {
      title: text,
    },
    () =>
      h(
        'div',
        {
          style: { whiteSpace: 'nowrap', textOverflow: 'ellipsis', overflow: 'hidden' },
        },
        text,
      ),
  );
};

export const columns: BasicColumn[] = [
  {
    title: t('table.promotion.promotion_currency'),
    dataIndex: 'currency_name',
    customRender: ({ record }) =>
      h(cdBlockCurrency, { currencyName: currentyOptions[record.currency_id] }),
    align: 'center',
  },
  {
    title: '费率(%)',
    dataIndex: 'fee',
    // customRender: ({ record }) => {
    //   return setTooltip(record.fee);
    // },
    align: 'center',
  },
  {
    title: '更新时间',
    dataIndex: 'updated_at',
    customRender: ({ record }) => {
      const stringDate = dayjs(record.start_time).format('YYYY-MM-DD HH:mm:ss');
      return stringDate;
    },
    align: 'center',
  },
];
